/**
 * Copyright (c) 2016 Lenovo Group
 * All Rights Reserved.
 * 
 * Project Name:lmrp-api
 * Create Time: 2016年1月21日 下午5:29:05
 */
package com.lenovo.lmrp.api.assigntrace;

import java.util.List;
import java.util.Map;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

import com.lenovo.lmrp.api.model.RestResponse;
import com.lenovo.lmrp.api.model.view.AttachmentVO;
import com.lenovo.lmrp.api.model.view.SearchListFilter;
import com.lenovo.lmrp.api.model.view.TicketCost;
import com.lenovo.lmrp.api.model.view.TicketStatistics;
import com.lenovo.sdc.framework.util.AttributeBean;

/**
 * @author songyz
 *
 */

@Produces("application/json;charset-utf-8")
@Consumes("application/json;charset-utf-8")
public interface ITraceTicket {

	/**
	 * Query entity data set 查询实体数据集
	 * 
	 * @param <T>
	 * 
	 * @param itsmcode
	 * @param entity
	 * @param pageNum
	 * @param limit
	 * @param timeRange
	 * @param status
	 * @param project
	 * @param sort
	 * @param includes
	 * @return
	 */
	@POST
	@Path("/{itsmcode}/entities/{entity}")
	public <T> RestResponse<List<T>> getEntityList(@PathParam("itsmcode") String itsmcode,
			@PathParam("entity") String entity, SearchListFilter filter);

	/**
	 * Query the total number of entity for engnierr 查询工程师能够抢单的总数和接单的总数
	 * 
	 * @param itsmcode
	 * @param entity
	 * @param engnieer
	 * @return
	 */
	@GET
	@Path("/{itsmcode}/entities/total/{entity}/{engnieer}")
	public <T> RestResponse<T> getEntityTotal(@PathParam("itsmcode") String itsmcode,
			@PathParam("entity") String entity, @PathParam("engnieer") String engnieer);

	/**
	 * Query entity object detail 查询实体对象明细
	 * 
	 * @param <T>
	 * 
	 * @param itsmcode
	 * @param entity
	 * @param entityid
	 * @param includes
	 * @return
	 */
	@GET
	@Path("/{itsmcode}/entities/{entity}/{entityid}")
	public <T> RestResponse<T> getEntityDetail(@PathParam("itsmcode") String itsmcode,
			@PathParam("entity") String entity, @PathParam("entityid") String entityid,
			@QueryParam("includes") String includes);

	/**
	 * update the work order 更新工单 action有如下值 reject, confirm, appoint, signin,
	 * pickparts, attach, evaluate, close,breakoff
	 * 
	 * @param itsmcode
	 * @param ticketid
	 * @param action
	 * @param fieldsl
	 */
	@PUT
	@Path("/{itsmcode}/tickets/{ticketid}/{action}")
	public RestResponse<String> updateTicket(@PathParam("itsmcode") String itsmcode,
			@PathParam("ticketid") String ticketid, @PathParam("action") String action, Map<String, String> fields);

	/**
	 * Upload the repair order in the attachment 上传工单附件,重名文件将加编号，不进行覆盖
	 * 
	 * @param itsmcode
	 * @param ticketid
	 * @param attachmentVO
	 */
	@POST
	@Path("/{itsmcode}/tickets/{ticketid}/attachments")
	public void uploadAttachment(@PathParam("itsmcode") String itsmcode, @PathParam("ticketid") String ticketid,
			AttachmentVO attachmentVO);

	/**
	 * The repair order statistics 工单统计
	 * 
	 * @param itsmcode
	 * @param conditions
	 * @param groupby
	 * @param orderby
	 * @return
	 */
	@GET
	@Path("/{itsmcode}/tickets/statistics")
	public RestResponse<TicketStatistics> ticketsStatistics(@PathParam("itsmcode") String itsmcode,
			@QueryParam("conditions") String conditions, @QueryParam("groupby") String groupby,
			@QueryParam("orderby") String orderby);

	/**
	 * Query order cost 查询工单费用,只支持查最近三个月内的工单费用
	 * 
	 * @param itsmcode
	 * @param ticketid
	 * @return
	 */
	@GET
	@Path("/{itsmcode}/tickets/{ticketid}/balance")
	public RestResponse<TicketCost> getTicketCost(@PathParam("itsmcode") String itsmcode,
			@PathParam("ticketid") String ticketid);

	/**
	 * Query engineers on my bill 查询工程师月结账
	 * 
	 * FIXME 返回值类型还未定义
	 * 
	 * @param itsmcode
	 * @param engineerid
	 * @return
	 */
	@GET
	@Path("/{itsmcode}/engineers/{engineerid}/balance")
	public Object getEngineersBill(@PathParam("itsmcode") String itsmcode, @PathParam("engineerid") String engineerid);

	/**
	 * 查询工程师抢单是否成功
	 * 
	 * @param itsmcode
	 * @param ticketid
	 * @return
	 */
	@GET
	@Path("/{itsmcode}/tickets/grab/result/{engineerid}/{ticketid}")
	public RestResponse<Object> getGrabResult(@PathParam("itsmcode") String itsmcode,
			@PathParam("engineerid") String engineerid, @PathParam("ticketid") String ticketid);

	/**
	 * 获取退单页面中的cc成员
	 * 
	 * @param itsmcode
	 * @param ticketid
	 * @return
	 */
	@GET
	@Path("/{itsmcode}/tickets/{ticketid}/projectEngineers")
	public RestResponse<List<Map<String, String>>> getProjectEngineers(@PathParam("itsmcode") String itsmcode,
			@PathParam("ticketid") String ticketid);
}
